package 冒泡排序;

public class Demo {

    /**
     * @param args
     */
    public static void main(String[] args) {
        int[] arr = {6, 1, 3, 9, 6, 4, 0, 12, 5};
        int num;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    num = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = num;
                }
            }
        }
        for (int i : arr) {
            System.out.print(i + " ");
        }


        int[] array = {2, 5, 7, 1, 7};
        int n;
        for (int i = 0; i < array.length; i ++) {
            for (int j = 0; j < array.length - i - 1; j ++) {
                if (array[j] >  array[j + 1]) {
                    n = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = n;
                }
            }
        }

        for (int i : array) {
            System.out.println(i);
        }
    }

}
